<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>2.事件传参</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <h2>学校名称：{{school}}</h2>
      <h2>学校地址：{{address}}</h2>
      <button @click="show1">查看联系方式</button> <br><br>
      <button @click="show2(3)">查看联系方式+楼层</button> <br><br>
      <button @click="show3(3,10)">查看联系方式+楼层+校龄</button> <br><br>
      <button @click="show4(3,10,$event)">查看联系方式+楼层+校龄+打印事件对象</button> <br><br>
      <button @click="show5(school)">查看学校名</button> <br><br>

      <!-- 下面这两个写法，有点傻，不要这么写 -->
      <!-- <button @click="show1($event)">测试</button> -->
      <!-- <button @click="show1()">测试</button> -->
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          school:'尚硅谷',
          address:'宏福科技园',
          tel:'010-56253825'
        },
        methods:{
          show1(event){
            console.log(event)
            alert(this.tel)
          },
          show2(n){
            alert(`电话：${this.tel}，所在楼层：${n}`)
          },
          show3(floor,age){
            alert(`电话：${this.tel}，所在楼层：${floor}，校龄：${age}`)
          },
          show4(floor,age,event){
            console.log(event)
            alert(`电话：${this.tel}，所在楼层：${floor}，校龄：${age}`)
          },
          show5(name){
            alert(name)
          }
        }
      })
    </script>
  </body>
</html>